using UnityEngine;
using System.Collections;

public class SimpleMenuItem : InteractiveDisplay {

	public bool _selected;
	public string _text;
	public GUIStyle _selectedTextStyle;
	public GUIStyle _unselectedTextStyle;
	public int _index;
	
	private SelectionMenu _menu;
	
	public SelectionMenu Menu{
		get {
		 return _menu;	
		}
	}
	
	void Start(){
		
		IDisplay _myDisplay = this;
		do {
			_myDisplay  = _myDisplay.transform.parent.GetComponent<IDisplay>();
		} while ( !(_myDisplay is SelectionMenu));	
		
		_menu = (SelectionMenu) _myDisplay;
		_menu.MenuItems.Add( _index, this);
	}
	
	public void OnGUI(){
		if (Render)
			if (_selected) {
				GUI.Label(Dimension, _text, _selectedTextStyle);
			} else {
				GUI.Label(Dimension, _text, _unselectedTextStyle);
			}
	}	
	
	public override void DoSomeThing(KeyCode k) {
		

		AbstractMenuScript menuScript = gameObject.GetComponent<AbstractMenuScript>();
		if (menuScript != null) {
			menuScript.Run(k);
		}
		
	}
	
	public override void DoSomeThing(KeyCode k, ControlSceme c) {
		DoSomeThing(k);
	}
	
	
}
